﻿<%@ Page Title="Business Plan" Language="C#" MasterPageFile="~/Main.Master" AutoEventWireup="true"
    CodeBehind="DealerTarget.aspx.cs" Inherits="VSM.DealerTarget" %>

<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc1" %>

<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
    <script type="text/javascript">
        function isNumberKey(sender, evt) {
            var txt = sender.value;
            var dotcontainer = txt.split('.');
            var charCode = (evt.which) ? evt.which : event.keyCode;
            if (!(dotcontainer.length == 1 && charCode == 46) && charCode > 31 && (charCode < 48 || charCode > 57))
                return false;

            return true;
        }

        function onCalendarShown() {
            var cal = $find("calendar1");
            cal._switchMode("years", true);
            if (cal._yearsBody) {
                for (var i = 0; i < cal._yearsBody.rows.length; i++) {
                    var row = cal._yearsBody.rows[i];
                    for (var j = 0; j < row.cells.length; j++) {
                        Sys.UI.DomEvent.addHandler(row.cells[j].firstChild, "click", call);
                    }
                }
            }
        }

        function onCalendarHidden() {
            var cal = $find("calendar1");
            if (cal._yearsBody) {
                for (var i = 0; i < cal._yearsBody.rows.length; i++) {
                    var row = cal._yearsBody.rows[i];
                    for (var j = 0; j < row.cells.length; j++) {
                        Sys.UI.DomEvent.removeHandler(row.cells[j].firstChild, "click", call);
                    }
                }
            }
        }

        function call(eventElement) {
            var target = eventElement.target;
            switch (target.mode) {
                case "year":
                    var cal = $find("calendar1");
                    cal.set_selectedDate(target.date);
                    cal._blur.post(true);
                    cal.raiseDateSelectionChanged(); break;
            }
        }

        function OpenDocList(docktype, payNoDoc) {
            var url = "../../DocumentList.aspx?DocType=" + docktype + "&PayNoDoc=" + payNoDoc
            Main.openCustomDialog(url, 800, 610);
        }
    </script>
    <div>
        <asp:UpdatePanel ID="updatePanel" runat="server" UpdateMode="Conditional">
            <ContentTemplate>
                <asp:HiddenField ID="hdnIsUpdate" runat="server" />
                <asp:HiddenField ID="hdnStatus" runat="server" />
                <h2>
                    &nbsp;<asp:Label ID="lblTitle" runat="server" Text="Business Plan"></asp:Label>
                </h2>
                <div style="margin-left: 5px; width: 99%;">
                    <hr />
                    <table border="0" width="100%" style="background-color: #D1D4D8; font-weight: bold;">
                        <tr>
                            <td style="border-bottom: dotted 1px #808080; vertical-align: bottom; width: 10%;">
                                <asp:Label ID="lblDealer" runat="server" Text="Dealer:"></asp:Label>
                            </td>
                            <td style="width: 80%;" colspan="3">
                                <asp:DropDownList ID="ddlDealer" Width="99%" runat="server"></asp:DropDownList>
                            </td>
                            <td align="right">
                                <asp:Button ID="btnSearch" runat="server" BorderStyle="Solid" 
                                    Style="background-image: url('/Images/bgButton.png'); background-repeat: no-repeat;" 
                                    Text="Search" Width="60px" onclick="btnSearch_Click" />
                            </td>
                        </tr>
                        <tr>
                            <td style="border-bottom: dotted 1px #808080; vertical-align: bottom; height: 7px">
                                <asp:Label ID="lblYear" runat="server" Text="Year:"></asp:Label>
                            </td>
                            <td style="height: 7px; width: 20%" colspan="4">
                                <asp:TextBox ID="txtStartMonthYear" runat="server" Height="20px" Width="40px">2014</asp:TextBox>
                                <cc1:CalendarExtender ID="txtStartMonthYear_CalendarExtender" runat="server" 
                                    BehaviorID="calendar1" Format="yyyy" OnClientHidden="onCalendarHidden" 
                                    OnClientShown="onCalendarShown" PopupButtonID="imgStartMonthYear" 
                                    TargetControlID="txtStartMonthYear">
                                </cc1:CalendarExtender>
                                <asp:ImageButton ID="imgStartMonthYear" runat="Server" 
                                    AlternateText="Click to show calendar" 
                                    ImageUrl="~/Images/Calendar_scheduleHS.png" />
                            </td>
                        </tr>
                        <tr>
                            <td style="border-bottom: dotted 1px #808080; vertical-align: bottom; height: 7px">
                                <asp:Label ID="lblType" runat="server" Text="Sales Type:"></asp:Label>
                            </td>
                            <td style="height: 7px; width: 20%" colspan="4">
                                <asp:DropDownList ID="ddlType" runat="server" Width="25%">
                                    <asp:ListItem Value="0">Whole Sales</asp:ListItem>
                                    <asp:ListItem Value="1">Retail Sales</asp:ListItem>
                                </asp:DropDownList>
                            </td>
                        </tr>
                    </table>
                    <table id="Table1" width="100%" style="font-weight: bold">
                        <tr >
                            <td class="FormLineItemAlt" style="display:none;" valign="middle">
                                <asp:Button ID="btnAddItems" runat="server" Text="Add new sales plan"                                    
                                    Style="background-image: url('/Images/bgButton.png'); background-repeat: no-repeat;" 
                                    Width="120px" onclick="btnAddItems_Click" Enabled="False" />                            
                            </td>
                            <td class="FormLineItemAlt" valign="middle" >
                                                         
                                <asp:Button ID="btnGetTemplate" runat="server" onclick="btnGetTemplate_Click" 
                                    Style="background-image: url('/Images/bgButton.png'); background-repeat: no-repeat;" 
                                    text="Get Template" Width="90px" />
                                <asp:FileUpload ID="FileUploadControl" runat="server" />
                                <asp:Button ID="btnImport" runat="server" onclick="btnImport_Click" 
                                    Style="background-image: url('/Images/bgButton.png'); background-repeat: no-repeat;" 
                                    text="Import" Width="60px" />
                                                         
                            </td>
                        </tr>
                    </table>
                    <hr />
                    <div style="width: 100%">
                        <asp:GridView ID="grvSO" CssClass="GridInner" runat="server" Width="100%" BorderColor="White"
                            BackColor="White" AllowSorting="True" AutoGenerateColumns="False" CellPadding="2"
                            HeaderStyle-Height="27px" CellSpacing="2" HeaderStyle-VerticalAlign="Middle"
                            AllowPaging="True" OnPageIndexChanging="grvSearchResult_PageIndexChanging" 
                            PageSize="20" onrowcreated="grvSO_RowCreated" 
                            onrowdatabound="grvSearchResult_RowDataBound">
                            <PagerSettings Mode="NumericFirstLast" />
                            <PagerStyle BackColor="#70A0D0" Font-Bold="True" HorizontalAlign="Center" VerticalAlign="Middle" />
                            <RowStyle BackColor="#D9E0ED" BorderColor="White" BorderWidth="2px" Height="25px" />
                            <AlternatingRowStyle BackColor="#EEF1F7" BorderColor="White" BorderWidth="2px" />
                            <Columns>
                                <asp:CommandField HeaderText="Action" ShowDeleteButton="True" ShowEditButton="False"
                                    Visible="false" HeaderStyle-HorizontalAlign="Center" ItemStyle-HorizontalAlign="Center" ItemStyle-Width="70px" />
                                <%--<asp:TemplateField HeaderText="Action">
                                    <ItemStyle HorizontalAlign="Center" Width="20px" />
                                    <HeaderStyle VerticalAlign="Middle" />
                                    <ItemTemplate>
                                        <asp:LinkButton ID="lnkDelete" runat="server" Text="Delete" TabIndex="-1" OnClick="lnkDelete_Click"></asp:LinkButton>
                                    </ItemTemplate>
                                </asp:TemplateField>--%>
                                <asp:TemplateField HeaderText="#">
                                    <ItemStyle HorizontalAlign="Center" Width="20px" />
                                    <HeaderStyle VerticalAlign="Middle" />
                                    <ItemTemplate>
                                        <asp:Label ID="lblNo" runat="server" Text='<%# Bind("No") %>' BorderStyle="none">
                                        </asp:Label>
                                    </ItemTemplate>
                                </asp:TemplateField>

                                <asp:TemplateField HeaderText="Dealer Name" Visible="false">
                                    <ItemStyle HorizontalAlign="Center" />
                                    <HeaderStyle VerticalAlign="Middle" Font-Bold="true" />
                                    <ItemTemplate>
                                        <asp:DropDownList ID="ddlDealerName" AutoPostBack="true" onselectedindexchanged="ddlDealerName_SelectedIndexChanged" 
                                            style="width: 98%;height:20px;" runat="server">
                                        </asp:DropDownList>
                                        <asp:HiddenField ID="hdnCarsCode" runat="server"  Value='<%# Bind("CardCode") %>'/>
                                    </ItemTemplate>
                                </asp:TemplateField>

                                <asp:TemplateField HeaderText="Model">
                                    <ItemStyle HorizontalAlign="Center"/>
                                    <HeaderStyle VerticalAlign="Middle" Font-Bold="true" />
                                    <ItemTemplate>
                                        <asp:DropDownList ID="ddlModel" AutoPostBack="true" onselectedindexchanged="ddlModel_SelectedIndexChanged" 
                                            BackColor="Transparent"  BorderStyle="None" Enabled="false" style="width: 98%;height:20px; " runat="server">
                                        </asp:DropDownList>
                                        <asp:HiddenField ID="hdnModel" runat="server"  Value='<%# Bind("Model") %>'/>
                                    </ItemTemplate>
                                </asp:TemplateField>

                                <asp:TemplateField HeaderText="Product">
                                    <ItemStyle HorizontalAlign="Center" BorderStyle="None"/>
                                    <HeaderStyle VerticalAlign="Middle" Font-Bold="true" />
                                    <ItemTemplate>
                                        <asp:DropDownList ID="ddlProduct" AutoPostBack="true" onselectedindexchanged="ddlProduct_SelectedIndexChanged" 
                                            BackColor="Transparent"  BorderStyle="None" Enabled="false" style="width: 98%;height:20px;" runat="server">
                                        </asp:DropDownList>
                                        <asp:HiddenField ID="hdnProduct" runat="server"  Value='<%# Bind("Product") %>'/>
                                    </ItemTemplate>
                                </asp:TemplateField>

                                <asp:TemplateField HeaderText="Jan.">
                                    <ItemStyle HorizontalAlign="Right" />
                                    <HeaderStyle VerticalAlign="Middle" Width="50px" />
                                    <ItemTemplate>
                                        <asp:TextBox ID="txtQuantity_01" runat="server" Width="97%" Text='<%# Bind("QtyTarget_01") %>' AutoPostBack="true"
                                            OnTextChanged="txtQtyTarget_OnTextChanged" OnKeyPress="return isNumberKey(this, event);" Style="text-align: right" Height="20px"/>
                                        <asp:HiddenField ID="hdnInternalID_01" runat="server"  Value='<%# Bind("internal_id_01") %>'/>
                                    </ItemTemplate>
                                </asp:TemplateField>
                                <asp:TemplateField HeaderText="Feb.">
                                    <ItemStyle HorizontalAlign="Right" />
                                    <HeaderStyle VerticalAlign="Middle" Width="50px" />
                                    <ItemTemplate>
                                        <asp:TextBox ID="txtQuantity_02" runat="server" Width="97%" Text='<%# Bind("QtyTarget_02") %>' AutoPostBack="true"
                                            OnTextChanged="txtQtyTarget_OnTextChanged" OnKeyPress="return isNumberKey(this, event);" Style="text-align: right" Height="20px"/>
                                        <asp:HiddenField ID="hdnInternalID_02" runat="server"  Value='<%# Bind("internal_id_02") %>'/>
                                    </ItemTemplate>
                                </asp:TemplateField>
                                <asp:TemplateField HeaderText="Mar.">
                                    <ItemStyle HorizontalAlign="Right" />
                                    <HeaderStyle VerticalAlign="Middle" Width="50px" />
                                    <ItemTemplate>
                                        <asp:TextBox ID="txtQuantity_03" runat="server" Width="97%" Text='<%# Bind("QtyTarget_03") %>' AutoPostBack="true"
                                            OnTextChanged="txtQtyTarget_OnTextChanged" OnKeyPress="return isNumberKey(this, event);" Style="text-align: right" Height="20px" />
                                        <asp:HiddenField ID="hdnInternalID_03" runat="server"  Value='<%# Bind("internal_id_03") %>'/>
                                    </ItemTemplate>
                                </asp:TemplateField>
                                <asp:TemplateField HeaderText="Apr.">
                                    <ItemStyle HorizontalAlign="Right" />
                                    <HeaderStyle VerticalAlign="Middle" Width="50px" />
                                    <ItemTemplate>
                                        <asp:TextBox ID="txtQuantity_04" runat="server" Width="97%" Text='<%# Bind("QtyTarget_04") %>' AutoPostBack="true"
                                            OnTextChanged="txtQtyTarget_OnTextChanged" OnKeyPress="return isNumberKey(this, event);" Style="text-align: right" Height="20px" />
                                        <asp:HiddenField ID="hdnInternalID_04" runat="server"  Value='<%# Bind("internal_id_04") %>'/>
                                    </ItemTemplate>
                                </asp:TemplateField>
                                <asp:TemplateField HeaderText="May.">
                                    <ItemStyle HorizontalAlign="Right" />
                                    <HeaderStyle VerticalAlign="Middle" Width="50px" />
                                    <ItemTemplate>
                                        <asp:TextBox ID="txtQuantity_05" runat="server" Width="97%" Text='<%# Bind("QtyTarget_05") %>' AutoPostBack="true"
                                            OnTextChanged="txtQtyTarget_OnTextChanged" OnKeyPress="return isNumberKey(this, event);" Style="text-align: right" Height="20px"/>
                                        <asp:HiddenField ID="hdnInternalID_05" runat="server"  Value='<%# Bind("internal_id_05") %>'/>
                                    </ItemTemplate>
                                </asp:TemplateField>
                                <asp:TemplateField HeaderText="Jun.">
                                    <ItemStyle HorizontalAlign="Right" />
                                    <HeaderStyle VerticalAlign="Middle" Width="50px" />
                                    <ItemTemplate>
                                        <asp:TextBox ID="txtQuantity_06" runat="server" Width="97%" Text='<%# Bind("QtyTarget_06") %>' AutoPostBack="true"
                                            OnTextChanged="txtQtyTarget_OnTextChanged" OnKeyPress="return isNumberKey(this, event);" Style="text-align: right" Height="20px"/>
                                        <asp:HiddenField ID="hdnInternalID_06" runat="server"  Value='<%# Bind("internal_id_06") %>'/>
                                    </ItemTemplate>
                                </asp:TemplateField>
                                <asp:TemplateField HeaderText="Jul.">
                                    <ItemStyle HorizontalAlign="Right" />
                                    <HeaderStyle VerticalAlign="Middle" Width="50px" />
                                    <ItemTemplate>
                                        <asp:TextBox ID="txtQuantity_07" runat="server" Width="97%" Text='<%# Bind("QtyTarget_07") %>' AutoPostBack="true"
                                            OnTextChanged="txtQtyTarget_OnTextChanged" OnKeyPress="return isNumberKey(this, event);" Style="text-align: right" Height="20px"/>
                                        <asp:HiddenField ID="hdnInternalID_07" runat="server"  Value='<%# Bind("internal_id_07") %>'/>
                                    </ItemTemplate>
                                </asp:TemplateField>
                                <asp:TemplateField HeaderText="Aug.">
                                    <ItemStyle HorizontalAlign="Right" />
                                    <HeaderStyle VerticalAlign="Middle" Width="50px" />
                                    <ItemTemplate>
                                        <asp:TextBox ID="txtQuantity_08" runat="server" Width="97%" Text='<%# Bind("QtyTarget_08") %>' AutoPostBack="true"
                                            OnTextChanged="txtQtyTarget_OnTextChanged" OnKeyPress="return isNumberKey(this, event);" Style="text-align: right" Height="20px"/>
                                        <asp:HiddenField ID="hdnInternalID_08" runat="server"  Value='<%# Bind("internal_id_08") %>'/>
                                    </ItemTemplate>
                                </asp:TemplateField>
                                <asp:TemplateField HeaderText="Sep.">
                                    <ItemStyle HorizontalAlign="Right" />
                                    <HeaderStyle VerticalAlign="Middle" Width="50px" />
                                    <ItemTemplate>
                                        <asp:TextBox ID="txtQuantity_09" runat="server" Width="97%" Text='<%# Bind("QtyTarget_09") %>' AutoPostBack="true"
                                            OnTextChanged="txtQtyTarget_OnTextChanged" OnKeyPress="return isNumberKey(this, event);" Style="text-align: right" Height="20px"/>
                                        <asp:HiddenField ID="hdnInternalID_09" runat="server"  Value='<%# Bind("internal_id_09") %>'/>
                                    </ItemTemplate>
                                </asp:TemplateField>
                                <asp:TemplateField HeaderText="Oct.">
                                    <ItemStyle HorizontalAlign="Right" />
                                    <HeaderStyle VerticalAlign="Middle" Width="50px" />
                                    <ItemTemplate>
                                        <asp:TextBox ID="txtQuantity_10" runat="server" Width="97%" Text='<%# Bind("QtyTarget_10") %>' AutoPostBack="true"
                                            OnTextChanged="txtQtyTarget_OnTextChanged" OnKeyPress="return isNumberKey(this, event);" Style="text-align: right" Height="20px"/>
                                        <asp:HiddenField ID="hdnInternalID_10" runat="server"  Value='<%# Bind("internal_id_10") %>'/>
                                    </ItemTemplate>
                                </asp:TemplateField>
                                <asp:TemplateField HeaderText="Nov.">
                                    <ItemStyle HorizontalAlign="Right" />
                                    <HeaderStyle VerticalAlign="Middle" Width="50px" />
                                    <ItemTemplate>
                                        <asp:TextBox ID="txtQuantity_11" runat="server" Width="97%" Text='<%# Bind("QtyTarget_11") %>' AutoPostBack="true"
                                            OnTextChanged="txtQtyTarget_OnTextChanged" OnKeyPress="return isNumberKey(this, event);" Style="text-align: right" Height="20px" />
                                        <asp:HiddenField ID="hdnInternalID_11" runat="server"  Value='<%# Bind("internal_id_11") %>'/>
                                    </ItemTemplate>
                                </asp:TemplateField>
                                <asp:TemplateField HeaderText="Dec.">
                                    <ItemStyle HorizontalAlign="Right" />
                                    <HeaderStyle VerticalAlign="Middle" Width="50px" />
                                    <ItemTemplate>
                                        <asp:TextBox ID="txtQuantity_12" runat="server" Width="97%" Text='<%# Bind("QtyTarget_12") %>' AutoPostBack="true"
                                            OnTextChanged="txtQtyTarget_OnTextChanged" OnKeyPress="return isNumberKey(this, event);" Style="text-align: right" Height="20px"/>
                                        <asp:HiddenField ID="hdnInternalID_12" runat="server"  Value='<%# Bind("internal_id_12") %>'/>
                                    </ItemTemplate>
                                </asp:TemplateField>
                                <asp:TemplateField HeaderText="Total">
                                    <ItemStyle HorizontalAlign="Right" />
                                    <HeaderStyle VerticalAlign="Middle" Width="70px" />
                                    <ItemTemplate>
                                        <asp:Label ID="lblTotal" runat="server" Width="97%" Text='<%# Bind("Total") %>' />
                                    </ItemTemplate>
                                </asp:TemplateField>
                            </Columns>
                            <HeaderStyle BackColor="#6095C9" Font-Bold="true" ForeColor="#ffffff" Font-Overline="False"
                                Height="27px" VerticalAlign="Bottom" />
                            <EmptyDataTemplate>
                                <table class="GridInner" style="width: 100%; border-color: White;" border="1" rules="all" cellspacing="2" cellpadding="2">
                                    <tr valign="middle" style="height: 27px; color: white; font-weight: bold; text-decoration: none; background-color: rgb(96, 149, 201);">
                                        <th>
                                            <span>#</span>
                                        </th>
                                        <th>
                                            <span>Model</span>
                                        </th>
                                        <th>
                                            <span>Product</span>
                                        </th>
                                        <th>
                                            <span>Jan.</span>
                                        </th>
                                        <th>
                                            <span>Feb.</span>
                                        </th>
                                        <th>
                                            <span>Mar.</span>
                                        </th>
                                        <th>
                                            <span>Apr.</span>
                                        </th>
                                         <th>
                                            <span>May</span>
                                        </th>
                                        <th>
                                            <span>Jun.</span>
                                        </th>
                                        <th>
                                            <span>Jul.</span>
                                        </th>
                                        <th>
                                            <span>Aug.</span>
                                        </th>
                                        <th>
                                            <span>Sep.</span>
                                        </th>
                                        <th>
                                            <span>Oct.</span>
                                        </th>
                                        <th>
                                            <span>Nov.</span>
                                        </th>
                                        <th>
                                            <span>Dec.</span>
                                        </th>
                                        <th>
                                            <span>Total</span>
                                        </th>
                                    </tr>
                                    <tr>
                                        <td colspan="16">
                                            <span>No Data</span>
                                        </td>
                                    </tr>
                                </table>
                            </EmptyDataTemplate>
                        </asp:GridView>
                    </div>
                    <hr width="100%" />
                </div>
                <table width="100%" border="0">
                    <tr>
                        <td valign="top" style="width: 50%;">
                            <table>
                                <tr>
                                    <td style="width: 150px">
                                        <strong>Remarks:</strong>
                                    </td>
                                    <td style="width: 100%;">
                                        <asp:TextBox runat="server" ID="txtRemarks" Height="71px" TextMode="MultiLine" Width="98%"></asp:TextBox>
                                    </td>
                                </tr>
                            </table>
                        </td>
                        <td style="width: 50%;"></td>
                    </tr>
                    <tr>
                        <td colspan="2">
                            <div style="margin-left: 5px; width: 99%;">
                                <hr />
                            </div>
                            <table style="width: 100%">
                                <tr>
                                    <td style="width: 400px;">
                                        <asp:Button ID="btnSave" runat="server" Text="Save" Style="background-image: url('/Images/bgButton.png');
                                            background-repeat: no-repeat; color: White;" OnClick="btnSave_Click" 
                                            BorderStyle="Solid" Width="60px" Enabled="False" />
                                        <asp:Button ID="btnCancel" runat="server" Text="Cancel" Style="background-image: url('/Images/bgButton.png');
                                            background-repeat: no-repeat; color: White;" BorderStyle="Solid" 
                                            OnClick="btnCancel_Click" Width="60px" Enabled="False" />
                                    </td>
                                    <td>
                                        <asp:Label ID="lblError" runat="server" Visible="False" Font-Bold="True" ForeColor="Red"></asp:Label>
                                    </td>
                                </tr>
                                <tr>
                                    <td colspan="2">
                                    </td>
                                </tr>
                            </table>
                        </td>
                    </tr>
                </table>
            </ContentTemplate>
            <Triggers>
                <asp:PostBackTrigger  ControlID="btnImport" />
                 <asp:PostBackTrigger  ControlID="btnGetTemplate" />
            </Triggers>
        </asp:UpdatePanel>
    </div>
</asp:Content>
